// pages/completeOrder/completeOrder.js
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        no_data_tips:true
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        this.get_storage();
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    get_storage: function () {
        var that = this;
        wx.getStorage({
            key: 'memberInfo',
            success: function (res) {
                var data = res.data;
                var member_id = data.id;
                var open_id = data.open_id;
                that.setData({
                    member_id: member_id,
                    open_id: open_id
                })
                that.order_list(member_id)
            }
        })
    },
    order_list: function (member_id) {
        var that = this;
        var params = {};
        params['id'] = member_id;
        params['mall_status'] = 3;
        wx.request({
            url: app.config() + "member/memberOrder",
            data: params,
            header: {
                'content-type': 'application/json'
            },
            success: function (res) {
                var data = res.data.data;
                var len=data.length;
                if(len){
                    for (var i = 0; i < len; i++) {
                        data[i].product_number = data[i].product_order.length;
                        data[i].total_pay_money = parseInt(data[i].pay_money) + parseInt(data[i].order_rest_pay_money)
                    }
                    
                }else{
                    that.setData({
                        no_data_tips: false
                    })
                }
                that.setData({
                    order_list: data
                })
            }
        })
    },//查看订单详情
    to_order_details: function (e) {
        var order_id = e.currentTarget.dataset.order_id;
        wx.navigateTo({
            url: '../../pages/wattingReceiptOrderInfo/wattingReceiptOrderInfo?order_id=' + order_id,
        })
    }
})